from typing import Dict, TypeVar, ClassVar
from pydantic import BaseModel
from typing import Dict, Union


class ProductConfig(BaseModel):
    api_url: str
    excel_file: Union[str, Dict[str, str]]


class ChartSettings(BaseModel):
    TARGET_VALUE: int = 55000
    WARNING_VALUE: int = 30000


class Settings(BaseModel):
    PRODUCTS: Dict[str, "ProductConfig"]
    CACHE_DURATION: int
    CHART_SETTINGS: ChartSettings = ChartSettings()  # 添加类型注解

    class Config:
        arbitrary_types_allowed = True


# 创建设置实例
settings = Settings(
    PRODUCTS={
        "素材神器": ProductConfig(
            api_url="https://scapi.tayunapi.com/ytest/dayPay",
            excel_file="data/素材神器.xlsx",
        ),
        "推文神器": ProductConfig(
            api_url="https://scapi.tayunyx.com/ytest/dayPay",
            excel_file="data/推文神器.xlsx",
        ),
        "追爱键盘": ProductConfig(
            api_url="https://jpapi.xmbita.com/bi/daypay",
            excel_file="data/追爱键盘.xlsx",
        ),
        "恋爱集合": ProductConfig(
            api_url="https://hsapi.psbzy.com/api/bi/dayPay",
            excel_file={
                "aibangzhu": "data/恋爱集合.xlsx",
                "aiqinghua": "data/恋爱集合.xlsx",
                "zhuiai": "data/恋爱集合.xlsx",
            },
        ),
    },
    CACHE_DURATION=300,  # 或其他你设置的缓存时间
    CHART_SETTINGS=ChartSettings(),  # 使用默认值
)
